package hello.test;

import static org.junit.Assert.*;
import hello.A11StringUtil;

import org.junit.Test;

public class CountWord {

	@Test
	public void strIsNull() {
		assertEquals(0, A11StringUtil.countWord(null, "any"));
	}

	@Test(expected = exception.ExceptionStringIsEmpty.class)
	public void strIsEmpty() {
		assertEquals(0, A11StringUtil.countWord(new String(), "any"));
	}

	@Test
	public void wordIsNull() {
		assertEquals(0, A11StringUtil.countWord("avd", null));
	}

	@Test(expected = exception.ExceptionStringIsEmpty.class)
	public void wordIsEmpty() {
		assertEquals(2, A11StringUtil.countWord("Hello world", new String()));
	}

	@Test
	public void wordLargerThanString() {
		assertEquals(0,
				A11StringUtil.countWord("hello world", "hahaahahahahahaahah"));
	}

	@Test(expected = exception.ExceptionCharIsNotDefine.class)
	public void wordNotContainUnexpectedCharater() {
		assertEquals(2, A11StringUtil.countWord("Hello world", "df &ds"));
	}

	@Test
	public void normalCase() {
		assertEquals(1, A11StringUtil.countWord("hello world", "hello"));
	}

	@Test(expected = exception.ExceptionCharIsNotDefine.class)
	public void spaceCase() {
		assertEquals(2, A11StringUtil.countWord("hello  world   ", " "));
	}
}
